﻿using FluentNHibernate.Mapping;
using IsoCompte.Classe;

namespace IsoCompte.Map
{
    public class UtilisateurMap : ClassMap<Utilisateur>
    {
        public UtilisateurMap()
        {
            Log.Logger.Info("Debut UtilisateurMap");
            Log.Logger.Info("Mappage Id");
            Id(x => x.Id);
            Log.Logger.Info("Mappage Login");
            Map(x => x.Login).Unique();
            Log.Logger.Info("Mappage MotDePasse");
            Map(x => x.MotDePasse);
            Log.Logger.Info("Mappage Utilisateurs");
            HasMany(x => x.Comptes).KeyColumn("UtilisateurId");
            Log.Logger.Info("Définition table");
            Table("Utilisateurs");
            Log.Logger.Info("Fin UtilisateurMap");
        }
    }

    public class CompteMap : ClassMap<Compte>
    {
        public CompteMap()
        {
            Log.Logger.Info("Début CompteMap");
            Log.Logger.Info("Mappage Id");
            Id(x => x.Id);
            Log.Logger.Info("Mappage Libelle");
            Map(x => x.Libelle);
            Log.Logger.Info("Mappage SoldeInitial");
            Map(x => x.SoldeInitial);
            Log.Logger.Info("Mappage Banque");
            Map(x => x.Banque);
            Log.Logger.Info("Mappage Guichet");
            Map(x => x.Guichet);
            Log.Logger.Info("Mappage NoCompte");
            Map(x => x.NoCompte);
            Log.Logger.Info("Mappage Clef");
            Map(x => x.Clef);
            Log.Logger.Info("Mappage MinGraphSold");
            Map(x => x.MinGraphSold);
            Log.Logger.Info("Mappage MaxGraphSold");
            Map(x => x.MaxGraphSold);
            Log.Logger.Info("Mappage SeuilAlerte");
            Map(x => x.SeuilAlerte);
            Log.Logger.Info("Mappage SeuilAlerteFinal");
            Map(x => x.SeuilAlerteFinal);
            Log.Logger.Info("Mappage TypEvol");
            Map(x => x.TypEvol);
            Log.Logger.Info("Mappage Iban");
            Map(x => x.Iban);
            Log.Logger.Info("Mappage Bic");
            Map(x => x.Bic);
            Log.Logger.Info("Mappage Titulaire");
            Map(x => x.Titulaire);
            Log.Logger.Info("Mappage Domiciliation");
            Map(x => x.Domiciliation);
            Log.Logger.Info("Mappage IdUtilisateur");
            References(x => x.Utilisateur).Column("IdUtilisateur");
            Log.Logger.Info("Définition table");
            Table("Comptes");
        }
    }

    public class CategorieMap : ClassMap<Categorie>
    {
        public CategorieMap()
        {
            Log.Logger.Info("Début CategorieMap");
            Log.Logger.Info("Mappage Id");
            Id(x => x.Id);
            Log.Logger.Info("Mappage Libelle");
            Map(x => x.Libelle);
            Log.Logger.Info("Mappage IdParent");
            References(x => x.CategorieParent).Column("IdParent").Nullable();
            Log.Logger.Info("Définition Table");
            Table("Categories");
        }
    }

    public class ModePaiementMap : ClassMap<ModePaiement>
    {
        public ModePaiementMap()
        {
            Log.Logger.Info("Début ModePaiementMap");
            Log.Logger.Info("Mappage Id");
            Id(x => x.Id);
            Log.Logger.Info("Mappage Libelle");
            Map(x => x.Libelle);
            Log.Logger.Info("Mappage Type");
            Map(x => x.Type);
            Log.Logger.Info("Définition table");
            Table("ModePaiements");
            Log.Logger.Info("Fin ModePaiementMap");
        }
    }

    public class OperationMap : ClassMap<Operation>
    {
        public OperationMap()
        {
            Log.Logger.Info("Début OperationMap");
            Log.Logger.Info("Mappage Id");
            Id(x => x.Id);
            Log.Logger.Info("Mappage Date");
            Map(x => x.Date);
            Log.Logger.Info("Mappage Tiers");
            Map(x => x.Tiers);
            Log.Logger.Info("Mappage Libelle");
            Map(x => x.Libelle);
            Log.Logger.Info("Mappage Montant");
            Map(x => x.Montant);
            Log.Logger.Info("Mappage DatePointage");
            Map(x => x.DatePointage).Nullable();
            Log.Logger.Info("Mappage IdModePaiement");
            References(x => x.ModePaiement).Column("IdModePaiement");
            Log.Logger.Info("Mappage IdCategorie");
            References(x => x.Categorie).Column("IdCategorie");
            Log.Logger.Info("Mappage IdCompte");
            References(x => x.Compte).Column("IdCompte");
            Log.Logger.Info("Définition table");
            Table("Operations");
            Log.Logger.Info("Fin ChequeMap");
        }
    }

    public class ChequeMap : ClassMap<Cheque>
    {
        public ChequeMap()
        {
            Log.Logger.Info("Début ChequeMap");
            Log.Logger.Info("Mappage Id");
            Id(x => x.Id);
            Log.Logger.Info("Mappage NumCheque");
            Map(x => x.NumCheque);
            Log.Logger.Info("Mappage NumChequier");
            Map(x => x.NumChequier);
            Log.Logger.Info("Mappage Operation");
            References(x => x.Operation).Column("IdOperation");
            Log.Logger.Info("Mappage Compte");
            References(x => x.Compte).Column("IdCompte");
            Log.Logger.Info("Définition table");
            Table("Cheques");
            Log.Logger.Info("Fin ChequeMap");
        }
    }

    public class EcheancierMap : ClassMap<Echeancier>
    {
        public EcheancierMap()
        {
            Log.Logger.Info("Début EcheancierMap");
            Log.Logger.Info("Mappage Id");
            Id(x => x.Id);
            Log.Logger.Info("Mappage Prochaine");
            Map(x => x.Prochaine);
            Log.Logger.Info("Mappage Tiers");
            Map(x => x.Tiers);
            Log.Logger.Info("Mappage Libelle");
            Map(x => x.Libelle);
            Log.Logger.Info("Mappage Montant");
            Map(x => x.Montant);
            Log.Logger.Info("Mappage Repete");
            Map(x => x.Repete);
            Log.Logger.Info("Mappage TypeRepete");
            Map(x => x.TypeRepete);
            Log.Logger.Info("Mappage DateFin");
            Map(x => x.DateFin);
            Log.Logger.Info("Mappage ModePaiement");
            References(x => x.ModePaiement).Column("IdModePaiement");
            Log.Logger.Info("Mappage Compte");
            References(x => x.Compte).Column("IdCompte");
            Log.Logger.Info("Mappage Categorie");
            References(x => x.Categorie).Column("IdCategorie");
            Log.Logger.Info("Définition table");
            Table("Echeanciers");
           

            Log.Logger.Info("Fin EcheancierMap");
        }
    }

    public class LienMap : ClassMap<Lien>
    {
        public LienMap()
        {
            Log.Logger.Info("Début LienMap");
            Log.Logger.Info("Mappage Id");
            Id(x => x.Id);
            Log.Logger.Info("Mappage TypeLien");
            Map(x => x.TypeLien);
            Log.Logger.Info("Mappage OrigineOperation");
            References(x => x.OrigineOperation).Column("IdOrigineOperation");
            Log.Logger.Info("Mappage DestinationOperation");
            References(x => x.DestinationOperation).Column("IdDestinationOperation");
            Log.Logger.Info("Définition table");
            Table("Liens");
        }
    }
}
